package com.tjbklx1.thread.chap01.practice06;

//方式三的改造 
public class EaterThread2 extends Thread {

	private String name;
	public final Pair pair;

	public EaterThread2(String name, Pair pair) {
		this.name = name;
		this.pair = pair;
	}

	@Override
	public void run() {
		while (true) {
			eat();
		}
	}

	private void eat() {
		synchronized (pair) {
			System.out.println(name + " takes up" + pair + " (left)");
			System.out.println(name + " eat ....");
			System.out.println(name + " puts down" + pair + " (left)");
		}

	}
}
